﻿/*
* Copyright (c) 2010-2012 Tesla Engine Group
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/


namespace Tesla.Graphics {
    /// <summary>
    /// Defines an interface for a render queue, which is a way to organize how renderables are to be drawn to the screen. A queue
    /// is composed of several buckets, each with an order. Renderables in each bucket can be sorted to further refine the organization.
    /// </summary>
    public interface IRenderQueue {

        /// <summary>
        /// Add a render bucket to the queue. Overwrites an existing bucket.
        /// </summary>
        /// <param name="type">Bucket type to add</param>
        /// <param name="bucket">Bucket to add</param>
        void AddRenderBucket(RenderBucketType type, IRenderBucket bucket);

        /// <summary>
        /// Gets a render bucket by its type.
        /// </summary>
        /// <param name="type">Type to get</param>
        /// <returns>Bucket, if it exists</returns>
        IRenderBucket GetRenderBucket(RenderBucketType type);

        /// <summary>
        /// Render each bucket in the queue.
        /// </summary>
        void RenderBuckets();

        /// <summary>
        /// Sort each bucket.
        /// </summary>
        void SortBuckets();

        /// <summary>
        /// Clear each bucket.
        /// </summary>
        void ClearBuckets();

        /// <summary>
        /// Sort, then render each bucket.
        /// </summary>
        void SortAndRender();

        /// <summary>
        /// Sort, render, then clear each bucket.
        /// </summary>
        void SortRenderClear();

        /// <summary>
        /// Adds the renderable to the queue.
        /// </summary>
        /// <param name="renderable">Renderable to add</param>
        /// <returns>True if it was added</returns>
        bool AddToQueue(IRenderable renderable);

        /// <summary>
        /// Removes the renderable from the queue.
        /// </summary>
        /// <param name="renderable">Renderable to remove</param>
        /// <returns>True if it was removed, if it was found</returns>
        bool RemoveFromQueue(IRenderable renderable);
    }
}
